{% extends 'base.html' %}
{% load static %}

{% block title %}创建世界杯 - Creeps Battle{% endblock %}

{% block extra_css %}
<style>
    .container {
        background: transparent;
        backdrop-filter: none;
        border-radius: 0;
        padding: 0;
        margin-top: 20px;
        margin-bottom: 20px;
        box-shadow: none;
        border: none;
        color: rgba(255, 255, 255, 0.9);
    }

    .create-form {
        max-width: 600px;
        margin: 0 auto;
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(30, 30, 60, 0.9) 100%);
        backdrop-filter: blur(15px);
        padding: 40px;
        border-radius: 20px;
        border: 2px solid rgba(255, 215, 0, 0.3);
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.3),
            0 0 20px rgba(255, 215, 0, 0.2),
            inset 0 0 15px rgba(255, 255, 255, 0.05);
    }

    .form-group {
        margin-bottom: 25px;
    }

    .form-group label {
        display: block;
        margin-bottom: 8px;
        font-weight: 600;
        color: #FFD700;
        font-size: 14px;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }

    .form-control {
        width: 100%;
        padding: 12px 15px;
        border: 2px solid rgba(255, 215, 0, 0.3);
        border-radius: 10px;
        font-size: 14px;
        background: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        transition: all 0.3s ease;
    }

    .form-control:focus {
        outline: none;
        border-color: #FFD700;
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
        background: rgba(255, 255, 255, 0.15);
    }

    .form-control::placeholder {
        color: rgba(255, 255, 255, 0.5);
    }

    .btn-group {
        display: flex;
        gap: 15px;
        justify-content: center;
        margin-top: 40px;
    }

    .btn {
        padding: 12px 30px;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        display: inline-block;
        text-align: center;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
    }

    .btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s ease;
    }

    .btn:hover::before {
        left: 100%;
    }

    .btn-primary {
        background: linear-gradient(135deg, #28a745, #20c997);
        color: white;
        box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
    }

    .btn-primary:hover {
        background: linear-gradient(135deg, #218838, #1e7e34);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
        color: white;
        text-decoration: none;
    }

    .btn-secondary {
        background: linear-gradient(135deg, #6c757d, #495057);
        color: white;
        box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
    }

    .btn-secondary:hover {
        background: linear-gradient(135deg, #5a6268, #343a40);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
        color: white;
        text-decoration: none;
    }

    .help-text {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
        margin-top: 5px;
        font-style: italic;
    }

    .page-header {
        text-align: center;
        margin-bottom: 40px;
        color: #FFD700;
        font-size: 2rem;
        font-weight: 700;
        text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    }

    .page-header::after {
        content: '';
        display: block;
        width: 60px;
        height: 3px;
        background: linear-gradient(135deg, #FFD700, #FFA500);
        margin: 15px auto 0;
        border-radius: 2px;
    }
</style>
{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="create-form">
        <h2 class="page-header">创建新的世界杯赛事</h2>

        <form method="post">
            {% csrf_token %}

            <div class="form-group">
                <label for="name">世界杯名称 *</label>
                <input type="text" id="name" name="name" class="form-control" required maxlength="100" placeholder="请输入世界杯名称">
                <div class="help-text">最多100个字符</div>
            </div>

            <div class="form-group">
                <label for="description">描述</label>
                <textarea id="description" name="description" class="form-control" rows="4" placeholder="请输入世界杯描述（可选）"></textarea>
                <div class="help-text">可选，用于描述本次世界杯的特色或规则</div>
            </div>

            <div class="form-group">
                <label for="round_limit">最大回合数</label>
                <input type="number" id="round_limit" name="round_limit" class="form-control" value="300" min="1" max="1000">
                <div class="help-text">每场对战的最大回合数，范围：1-1000</div>
            </div>

            <div class="form-group">
                <label for="time_limit">时间限制（秒）</label>
                <input type="number" id="time_limit" name="time_limit" class="form-control" value="30" min="1" max="300">
                <div class="help-text">每回合的时间限制，范围：1-300秒</div>
            </div>

            <div class="btn-group">
                <button type="submit" class="btn btn-primary">创建世界杯</button>
                <a href="{% url 'battles:worldcup_list' %}" class="btn btn-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
    // 表单验证
    document.querySelector('form').addEventListener('submit', function(e) {
        const name = document.getElementById('name').value.trim();
        const roundLimit = parseInt(document.getElementById('round_limit').value);
        const timeLimit = parseInt(document.getElementById('time_limit').value);

        if (!name) {
            alert('请输入世界杯名称');
            e.preventDefault();
            return;
        }

        if (roundLimit < 1 || roundLimit > 1000) {
            alert('最大回合数必须在1-1000之间');
            e.preventDefault();
            return;
        }

        if (timeLimit < 1 || timeLimit > 300) {
            alert('时间限制必须在1-300秒之间');
            e.preventDefault();
            return;
        }
    });
</script>
{% endblock %}